import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import qiankun from 'vite-plugin-qiankun'

// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
  const env = loadEnv(mode, process.cwd());
  console.log('==========',env);

  return {
    base: mode === 'production' ? '/iot/' : '/',
    server: {
      port: 5101, // 修改端口号为3000
      headers: {
        'Access-Control-Allow-Origin': '*', // 主应用获取子应用时跨域响应头
      },
    },
    plugins: [
      vue(),
      qiankun('iot', {
        useDevMode: true
      })
    ],
    resolve: {
      alias: {
        // '~': path.resolve(__dirname, './'),
        '@': path.resolve(__dirname, './src')
      },
      // extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
    }
  }
})
